package com.zyzd.general.module.tipdialog;

import android.content.Context;
import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.zyzd.commontools.utils.DeviceUtil;
import com.zyzd.general.R;
import com.zyzd.general.entity.local.TipDialogEntity;
import com.zyzd.retrofit.base.BaseAdapter;

/**
 * Created by lzy on 2018/6/5 0005.
 * description ${信息对话框 Adapter}
 */
public class TipDialogAdapter extends BaseAdapter<TipDialogAdapter.TipDialogHolder, TipDialogEntity> {

    public TipDialogAdapter(Context context) {
        super(context);
    }

    @NonNull
    @Override
    public TipDialogHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        return new TipDialogHolder(mInflater.inflate(R.layout.item_text, parent, false));
    }

    @Override
    public void onBindHolder(@NonNull TipDialogHolder holder, int position) {
        holder.tvContent.setText(getItem(position).getItemText());
        holder.tvContent.setTextSize(16);
        holder.tvContent.setGravity(Gravity.CENTER);
        holder.tvContent.setPadding(DeviceUtil.dpToPx(8), DeviceUtil.dpToPx(8), DeviceUtil.dpToPx(8), DeviceUtil.dpToPx(8));
    }

    static class TipDialogHolder extends RecyclerView.ViewHolder {
        final TextView tvContent;

        TipDialogHolder(View itemView) {
            super(itemView);
            tvContent = itemView.findViewById(R.id.tv_content);
        }
    }
}
